home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual dBase v5.5 / SAMPLES1.PAK / SYSINFO.WFM < prev    next >
Text File  |  1995-07-18  |  10KB  |  331 lines

  1. **************************************************************************
  2. *  PROGRAM:      Sysinfo.wfm
  3. *
  4. *  WRITTEN BY:   Borland Samples Group
  5. *
  6. *  DATE:         5/93
  7. *
  8. *  UPDATED:      7/94
  9. *
  10. *  REVISION:     $Revision:   1.49  $
  11. *
  12. *  VERSION:      Visual dBASE
  13. *
  14. *  DESCRIPTION:  This form displays information about your system.
  15. *                It uses Windows API functions called externally from
  16. *                Visual dBASE to obtain that information.
  17. *
  18. *  PARAMETERS:   None
  19. *
  20. *  CALLS:        Buttons.cc      (Custom Controls file)
  21. *
  22. *  USAGE:        do Sysinfo.wfm
  23. *                or
  24. *                set procedure to Sysinfo.wfm additive
  25. *                local f
  26. *                f = new SysInfo()
  27. *                f.mdi = .F.       && modal forms cannot be mdi
  28. *                f.ReadModal()
  29. *
  30. *******************************************************************************
  31. #include <Winapi.h>
  32. #define HIWORD(x)     (bitand(bitrshift(x,16),2^16-1))
  33. #define LOWORD(x)     (bitand(x,2^16-1))
  34. #define HIBYTE(x)     (bitand(bitrshift(x,8),2^8-1))
  35. #define LOBYTE(x)     (bitand(x,2^8-1))
  36. #define STRHIBYTE(x)  ltrim(str(HIBYTE(x)))
  37. #define STRLOBYTE(x)  ltrim(str(LOBYTE(x)))
  38.  
  39.  
  40.  
  41. create session
  42. set talk off
  43. set ldCheck off
  44.  
  45. ** END HEADER -- do not remove this line*
  46. * Generated on 07/11/95
  47. *
  48. parameter bModal
  49. local f
  50. f = new SYSINFOFORM()
  51. if (bModal)
  52.    f.mdi = .F. && ensure not MDI
  53.    f.ReadModal()
  54. else
  55.    f.Open()
  56. endif
  57. CLASS SYSINFOFORM OF FORM
  58.    Set Procedure To &_dbwinhome.samples\BUTTONS.CC additive
  59.    this.OnOpen = CLASS::ONOPEN
  60.    this.Width = 52.833
  61.    this.OnClose = CLASS::ONCLOSE
  62.    this.Top = 8.4111
  63.    this.MousePointer = 1
  64.    this.Left = 26.333
  65.    this.Text = "Windows System Information"
  66.    this.Height = 13.1172
  67.    this.Maximize = .F.
  68.    this.Minimize = .F.
  69.    this.MDI = .F.
  70.  
  71.    DEFINE RECTANGLE RECTANGLE1 OF THIS;
  72.        PROPERTY; 
  73.          Width 50.1807,;
  74.          Top 0.5391,;
  75.          Left 1.3193,;
  76.          Text "",;
  77.          Height 10.0488
  78.  
  79.    DEFINE TEXT INSTANCESTEXT OF THIS;
  80.        PROPERTY; 
  81.          Width 23.8604,;
  82.          Top 1.0596,;
  83.          Left 2.6396,;
  84.          Text "Visual dBASE Instances:",;
  85.          Height 1.3193,;
  86.          Alignment 2
  87.  
  88.    DEFINE TEXT WINVERSIONTEXT OF THIS;
  89.        PROPERTY; 
  90.          Width 23.8604,;
  91.          Top 2.3799,;
  92.          MousePointer 1,;
  93.          Left 2.6396,;
  94.          Text "Windows Version:",;
  95.          Height 1.2666,;
  96.          Alignment 2
  97.  
  98.    DEFINE TEXT MODETEXT OF THIS;
  99.        PROPERTY; 
  100.          Width 23.8604,;
  101.          Top 3.7197,;
  102.          MousePointer 1,;
  103.          Left 2.6396,;
  104.          Text "Mode of Operation:",;
  105.          Height 1.2803,;
  106.          Alignment 2
  107.  
  108.    DEFINE TEXT CPUTEXT OF THIS;
  109.        PROPERTY; 
  110.          Width 23.8604,;
  111.          Top 5.0391,;
  112.          MousePointer 1,;
  113.          Left 2.6396,;
  114.          Text "CPU Type:",;
  115.          Height 1.3193,;
  116.          Alignment 2
  117.  
  118.    DEFINE TEXT COPROCTEXT OF THIS;
  119.        PROPERTY; 
  120.          Width 23.8604,;
  121.          Top 6.3594,;
  122.          MousePointer 1,;
  123.          Left 2.6396,;
  124.          Text "Coprocessor Present:",;
  125.          Height 1.2871,;
  126.          Alignment 2
  127.  
  128.    DEFINE TEXT GLOBFREETEXT OF THIS;
  129.        PROPERTY; 
  130.          Width 23.8604,;
  131.          Top 7.6895,;
  132.          MousePointer 1,;
  133.          Left 2.6396,;
  134.          Text "Free Global Memory:",;
  135.          Height 1.3193,;
  136.          Alignment 2
  137.  
  138.    DEFINE TEXT DOSVERSTEXT OF THIS;
  139.        PROPERTY; 
  140.          Width 23.8604,;
  141.          Top 9.0098,;
  142.          MousePointer 1,;
  143.          Left 2.6396,;
  144.          Text "DOS Version:",;
  145.          Height 1.2842,;
  146.          Alignment 2
  147.  
  148.    DEFINE ENTRYFIELD INSTANCESENTRY OF THIS;
  149.        PROPERTY; 
  150.          Width 19.79,;
  151.          Top 1.0596,;
  152.          Left 27.71,;
  153.          ColorNormal "B/BtnFace",;
  154.          Height 1.3193,;
  155.          Enabled .F.,;
  156.          Border .F.,;
  157.          Value "                    "
  158.  
  159.    DEFINE ENTRYFIELD WINVERSIONENTRY OF THIS;
  160.        PROPERTY; 
  161.          Width 19.79,;
  162.          Top 2.3799,;
  163.          Left 27.71,;
  164.          ColorNormal "B/BtnFace",;
  165.          Height 1.2666,;
  166.          Enabled .F.,;
  167.          Border .F.,;
  168.          Value "                     "
  169.  
  170.    DEFINE ENTRYFIELD MODEENTRY OF THIS;
  171.        PROPERTY; 
  172.          Width 23.123,;
  173.          Top 3.7197,;
  174.          Left 27.71,;
  175.          ColorNormal "B/BtnFace",;
  176.          Height 1.2803,;
  177.          Enabled .F.,;
  178.          Border .F.,;
  179.          Value "                      "
  180.  
  181.    DEFINE ENTRYFIELD CPUENTRY OF THIS;
  182.        PROPERTY; 
  183.          Width 19.79,;
  184.          Top 5.0391,;
  185.          Left 27.71,;
  186.          ColorNormal "B/BtnFace",;
  187.          Height 1.3193,;
  188.          Enabled .F.,;
  189.          Border .F.,;
  190.          Value "                     "
  191.  
  192.    DEFINE ENTRYFIELD COPROCENTRY OF THIS;
  193.        PROPERTY; 
  194.          Width 19.79,;
  195.          Top 6.3594,;
  196.          Left 27.71,;
  197.          ColorNormal "B/BtnFace",;
  198.          Height 1.2871,;
  199.          Enabled .F.,;
  200.          Border .F.,;
  201.          Value "                      "
  202.  
  203.    DEFINE ENTRYFIELD GLOBFREEENTRY OF THIS;
  204.        PROPERTY; 
  205.          Width 19.79,;
  206.          Top 7.6895,;
  207.          Left 27.71,;
  208.          ColorNormal "B/BtnFace",;
  209.          Height 1.3193,;
  210.          Enabled .F.,;
  211.          Border .F.,;
  212.          Value "                      "
  213.  
  214.    DEFINE ENTRYFIELD DOSVERSENTRY OF THIS;
  215.        PROPERTY; 
  216.          Width 19.79,;
  217.          Top 9.0098,;
  218.          Left 27.71,;
  219.          ColorNormal "B/BtnFace",;
  220.          Height 1.2842,;
  221.          Enabled .F.,;
  222.          Border .F.,;
  223.          Value "                      "
  224.  
  225.    DEFINE CLOSEBUTTON CLOSEBUTTON1 OF THIS;
  226.        PROPERTY; 
  227.          Width 14.1934,;
  228.          Group .T.,;
  229.          Top 11.1396,;
  230.          Left 19.1396,;
  231.          Height 1.5
  232.  
  233.    procedure OnOpen
  234.    
  235.    * Called by Sysinfo().  This function makes the necessary API calls, and assigns
  236.    * the accessed information to variables that will be displayed in the form
  237.    * showing system information.
  238.    ********************************************************************************
  239.    *extern CLONG GetFreeSpace(CINT) KERNEL
  240.    
  241.    set procedure to &_dbwinhome.samples\Sampproc.prg additive && for Format functions
  242.    
  243.    local mHandle, mInstance, mFlags, mCpu, mFreeMem, wFreeMem, mCoprocess
  244.    
  245.    mHandle = GetModuleHandle(ansi("DBASEWIN.EXE"))   && Get Visual dBASE handle
  246.    ShowWindow(mHandle,7) && 7 make icon not active
  247.    mInstance = GetModuleUsage(mHandle)    && Number of Visual dBASE instances
  248.    mFlags = GetWinFlags()
  249.    do case                                && Check which mode Windows running in
  250.       case mFlags = BitOr(mFlags,2)
  251.          mMode = "Running Win286"
  252.       case mFlags = BitOr(mFlags,16)
  253.          mMode = "Standard Mode"
  254.       case mFlags = BitOr(mFlags,32)
  255.          mMode = "Enhanced Mode"
  256.    endcase
  257.    do case                                && Check processor type
  258.       case mFlags = BitOr(mFlags,8)
  259.          mCpu = "80486"
  260.       case mFlags = BitOr(mFlags,4)
  261.          mCpu = "80386"
  262.       case mFlags = BitOr(mFlags,2)
  263.          mCpu = "80286"
  264.       case mFlags = BitOr(mFlags,128)
  265.          mCpu = "80186"
  266.       case mFlags = BitOr(mFlags,64)
  267.          mCpu = "8086"
  268.    endcase
  269.    mCoprocess = IIF(mFlags = BitOr(mFlags,1024), "Yes", "No ")
  270.    mFreeMem = FormatStr("%1 K", ltrim(str(memo())))
  271.    wFreeMem = FormatStr("%1 K", ltrim(str(GetFreeSpace(0)/1024)))
  272.    
  273.    form.instancesEntry.value = ltrim(str(mInstance))
  274.    form.winVersionEntry.value = CLASS::GetVersion("WIN")   && Get Windows version
  275.    form.modeEntry.value = mMode
  276.    form.cpuEntry.value = mCpu
  277.    form.coprocEntry.value = mCoprocess
  278.    form.globFreeEntry.value = wFreeMem
  279.    form.dosVersEntry.value = CLASS::GetVersion("DOS")      && Get DOS version
  280.    
  281.    form.visible = .T.   && So you don't see all controls painting
  282.                         && while they are defined
  283.    
  284.    
  285.    ********************************************************************************
  286.  
  287.    procedure OnClose
  288.    ********************************************************************************
  289.    
  290.    close procedure &_dbwinhome.samples\Buttons.cc,;
  291.       &_dbwinhome.samples\Sampproc.prg
  292.    
  293.    
  294.    ********************************************************************************
  295.  
  296.    procedure GetVersion (verType)
  297.    
  298.    * Gets information from the Windows function
  299.    * GetVersion(), which returns the major and minor
  300.    * DOS and Windows versions as a CLONG.
  301.    *
  302.    *
  303.    * The "High Byte of the High Word" contains the
  304.    * major DOS version, the "Low Byte of the High Word"
  305.    * contains the minor DOS version. The "High Byte of
  306.    * the Low Word" specifies the minor version of
  307.    * Windows and the "Low byte of the Low Word"
  308.    * specifies the major Windows version. The Bit
  309.    * functions are used to extract the proper values.
  310.    * BitRshift(), BitAnd().
  311.    *
  312.    ********************************************************************************
  313.    * EXTERN CLONG GetVersion(CVOID)  KERNEL
  314.    
  315.    local version, retVal
  316.    
  317.    version = GetVersion( )
  318.    if upper(verType) = "DOS"
  319.       retVal = FormatStr("%1.%2",;
  320.          STRHIBYTE(HIWORD(version)), STRLOBYTE(HIWORD(version)))
  321.    elseif left(upper(verType),3) = "WIN"
  322.       retVal = FormatStr("%1.%2",;
  323.          STRLOBYTE(LOWORD(version)), STRHIBYTE(LOWORD(version)))
  324.    endif
  325.    
  326.    return retVal
  327.    
  328.    
  329. ENDCLASS
  330.  
  331.